
package com.hylink.bean;

import java.util.List;
import java.util.Map;

/**
 * @author ruyali
 * 
 */
public class Pager {
	// 排序方式
		public enum OrderType{
			asc, desc
		}
		
		public static final Integer MAX_PAGE_SIZE = 500;// 每页最大记录数限制
		private Integer pageNumber = 1;// 当前页码
		private Integer pageSize = 10;// 每页记录数
		private Integer totalCount = 0;// 总记录数
		private Integer pageCount = 0;// 总页数
		private Map<String,Object> queryBuilder; //查找属性及关键字名称，Key为属性名称，value为关键字
		private String orderBy = null;// 排序字段
		private OrderType orderType = null;// 排序方式
		private List<?> list;// 数据List


		public Integer getPageNumber() {
			return pageNumber;
		}

		public void setPageNumber(Integer pageNumber) {
			if (pageNumber < 1) {
				pageNumber = 1;
			}
			this.pageNumber = pageNumber;
		}

		public Integer getPageSize() {
			return pageSize;
		}

		public void setPageSize(Integer pageSize) {
			if (pageSize < 1) {
				pageSize = 1;
			} else if(pageSize > MAX_PAGE_SIZE) {
				pageSize = MAX_PAGE_SIZE;
			}
			this.pageSize = pageSize;
		}
		
		public Integer getTotalCount() {
			return totalCount;
		}

		public void setTotalCount(Integer totalCount) {
			this.totalCount = totalCount;
		}

		public Integer getPageCount() {
			pageCount = totalCount / pageSize;
			if (totalCount % pageSize > 0) {
				pageCount ++;
			}
			return pageCount;
		}

		public void setPageCount(Integer pageCount) {
			this.pageCount = pageCount;
		}

		public String getOrderBy() {
			return orderBy;
		}

		public void setOrderBy(String orderBy) {
			this.orderBy = orderBy;
		}
		
		public OrderType getOrderType() {
			return orderType;
		}

		public void setOrderType(OrderType orderType) {
			this.orderType = orderType;
		}

		public List<?> getList() {
			return list;
		}

		public void setList(List<?> list) {
			this.list = list;
		}

		/**
		 * @return the queryBuilder
		 */
		public Map<String, Object> getQueryBuilder() {
			return queryBuilder;
		}

		/**
		 * @param queryBuilder the queryBuilder to set
		 */
		public void setQueryBuilder(Map<String, Object> queryBuilder) {
			this.queryBuilder = queryBuilder;
		}
		
		
}
